import React, { Component } from 'react';
// import Count from '../1_setState';
export default class Parent extends Component {
  render() {
    return (
      <div className="parent">
        <h1>我是parent组件</h1>
        {/* 1、传递参数  children props*/}
        {/* <B>hello</B> */}
        {/* 2、传递参数（类似于vue的插槽技术）render props */}
        <A render={(name) => <B name={name} />}></A>
      </div>
    )
  }
}
class A extends Component {
  state = {
    name: 'xixi'
  }
  render() {
    const { name } = this.state
    return (
      <div className="child">
        <h1>我是A组件</h1>
        {this.props.render(name)}
      </div>
    )
  }
}
class B extends Component {
  render() {
    console.log(this.props)
    //接收参数
    // console.log(this.props.children)//hello
    return (
      <div className="grand">
        <h1>我是B组件,{this.props.name}</h1>
      </div>
    )
  }
}
